package com.example.sharding.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.sharding.service.ExampleService;
import com.example.sharding.service.UserService;
import com.example.sharding.service.impl.UserServiceImpl;
import com.example.sharding.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.jackson.JsonObjectDeserializer;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;

/**
 * Created by mazeyi on 2019/12/3.
 */
@RestController
@RequestMapping("/sharding")
public class TestController {

    @Autowired
    private UserService userService;

    @RequestMapping("/insert")
    public String test(){

        try {
            userService.processSuccess();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;

    }

    @RequestMapping("/select")
    public String select(String name){
        User user = userService.findByUserName(name);

        return JSONObject.toJSONString(user);
    }


}